package com.common;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;

public class BeanUtil {
	
	public static <T> T convertBeanByMap(Map<String, Object> map,Class<T> clazz){
		
		Map<String, Object> newMap=new HashMap<String, Object>();
		for(Map.Entry<String, Object> item:map.entrySet())
		{
			String newKey=StringProcess.toLowerCaseFirstOne(item.getKey());
			newMap.put(newKey, item.getValue());
		}
		
		return JSON.toJavaObject((JSON)JSON.toJSON(newMap), clazz);
	}
	
	public static <T> T convertBean(Map<?, ?> map,Class<T> clazz){
		return JSON.toJavaObject((JSON)JSON.toJSON(map), clazz);
	}
}
